package com.kingre.et.chart;

import java.awt.Font;

import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
import org.jfree.chart.plot.SpiderWebPlot;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.category.CategoryDataset;

/**
 * 刻度蜘蛛环图示例
 * 
 * @author 成尚謙 lhx222@gmail.com
 * @since 2011-09-14
 * @version 1.0
 */
public class SpiderChart {

    /**
     * 创建图表
     * 
     * @param categorydataset
     * @return
     */
    public static JFreeChart createChart(CategoryDataset categorydataset) {
        CustomSpiderWebPlot spiderwebplot = new CustomSpiderWebPlot(categorydataset);
        spiderwebplot.setToolTipGenerator(new StandardCategoryToolTipGenerator());// 标准分类提示器

        JFreeChart jfreechart = new JFreeChart("", TextTitle.DEFAULT_FONT, spiderwebplot, false);

        jfreechart.getTitle().setFont(new Font("宋体", Font.PLAIN, 16));
        SpiderWebPlot plot = (SpiderWebPlot) jfreechart.getPlot();
        plot.setLabelFont(new Font("黑体", 0, 12));
        plot.setAxisLabelGap(0.1d);
        plot.setInteriorGap(0.3D);

        // 应用标准的主题外观
        // ChartUtilities.applyCurrentTheme(jfreechart);
        return jfreechart;
    }

}
